﻿using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using SGRapidForm.Common;
namespace SGRapidForm.Extensions
{
    public class ContextReceivalCallContextInitializer : ICallContextInitializer
    {
        #region ICallContextInitializer Members

        public void AfterInvoke(object correlationState)
        {
        }

        public object BeforeInvoke(InstanceContext instanceContext, IClientChannel channel, Message message)
        {
            ApplicationContext.Current = message.Headers.GetHeader<ApplicationContext>(ApplicationContext.ContextHeaderLocalName, ApplicationContext.ContextHeaderNamespace);
            return null;
        }

        #endregion
    }
}